package com.znyj.cloud.device.task.model;

import com.znyj.cloud.device.pack.TaskSendPackage;
import io.netty.channel.ChannelHandlerContext;

/**
 * Created by gaoliwei02 on 17/6/3.
 */
public class ControlTaskModel extends AbstractTaskModel {
    private TaskSendPackage taskSendPackage;
    private int skipDelay;

    public ControlTaskModel(TaskSendPackage taskSendPackage,int skipDelay) {
        this.taskSendPackage = taskSendPackage;
        this.skipDelay = skipDelay;
    }

    public TaskSendPackage getTaskSendPackage() {
        return taskSendPackage;
    }

    @Override
    public void sendPackage(ChannelHandlerContext ctx) {
        taskSendPackage.generateAndSendPackage(ctx);
        //定时5秒查看task任务表，如果失败再发一次
        //查看report时如果5*2+1秒没有更新，则确定重发失败
    }

    public void decSkipDelay(){
        skipDelay--;
    }

    public int getSkipDelay() {
        return skipDelay;
    }

    public void setSkipDelay(int skipDelay) {
        this.skipDelay = skipDelay;
    }
}
